import React from 'react';
import { TRDefault } from '@/components/index.js';
import { DeclareDetailEcharts } from '../../../components/Charts/index.js';
import type { IShortForecastCurveAdjustmentDataType } from '../../../type';
import { IDeclareDetailChartsLineType } from '../../../type';
import styles from './index.less';

interface IProps {
  /**
   * 数据源
   */
  data?: IShortForecastCurveAdjustmentDataType[];
  /**
   * 申报时间
   */
  issueTime?: string;
  /**
   * 单位
   */
  unit?: string;
}

const DeclareDetailCharts = (props: IProps) => {
  const { data = [], issueTime = '', unit = 'MW' } = props;
  const _data = data.filter((item) => {
    return (
      item?.dataSourceName !== IDeclareDetailChartsLineType.LINE_THREE &&
      item?.dataSourceName !== IDeclareDetailChartsLineType.LINE_FOUR &&
      item?.dataSourceName !== IDeclareDetailChartsLineType.LINE_FIVE
    );
  });

  return (
    <div className={styles.container}>
      {data.length ? (
        <div className={styles.charts}>
          <DeclareDetailEcharts data={_data || []} date={issueTime} unit={unit} />
        </div>
      ) : (
        <TRDefault type={'emptysm'} message={'暂无数据'} />
      )}
    </div>
  );
};

export default DeclareDetailCharts;
